1. Batch Processing in Dynamics AX
In batch processing, you create batch jobs
to organize “batchable” tasks for processing, schedule and define the
conditions under which the batch tasks are executed, add the tasks to a
queue, and set them to run automatically on a batch server. After the
execution is completed, the batch server logs the errors and sends
alerts. For example, a batch job might involve printing reports, closing
inventory, performing maintenance, or sending electronic documents
using the Application Integration Framework (AIF)—at a specified time on
a specified computer. When you use a batch job to process these types
of resource-intensive tasks, you avoid slowing down the user’s computer
or the server during working hours.
In the following sections, we explain how each of these batch processing concepts are put into action in Dynamics AX.
Dynamics AX Batch Concepts
Table 1
describes how standard batch processing concepts are represented in
Dynamics AX.
Table 1. Batch Processing Concepts in Dynamics 2009
Batch Concept | In Dynamics AX 2009 |
---|
Batch framework | An
asynchronous server-based batch execution environment. The environment
is capable of executing multiple batch tasks within a batch job, in
parallel, across multiple instances of the Application Object Server
(AOS).
The Batch framework gives developers and
administrators the flexibility to control the schedule and the order in
which tasks are executed. For example, an administrator can set up a job
to process invoices automatically at the end of every month on a
specific AOS, and set up a different sequence of tasks depending on
whether an earlier task succeeds or fails.
The Batch framework also provides transaction control, logging, and alerting mechanisms. |
Batch task | A
batch-enabled class. A class must be enabled for batch processing
before it can run as a batch task, and any class that is batch-enabled
can execute as a batch task. The Dynamics AX classes that are used for batch tasks are
designated to run on either the client or the server. Tasks that run on
the server can run automatically as part of a batch job, regardless of
whether a client is open. However, tasks that run on the client must be
run manually by using the Batch processing form. |
Batch job | A
complete process that achieves a goal, such as printing a report or
performing the inventory closing process. A batch job is made up of one
or more tasks. |
Batch group | An
attribute of a batch task that allows the administrator to determine
which AOS runs the job. Batch groups are used to direct batch tasks to
specific servers.
If a new task is created, by default it is assigned to an
“empty” batch group, which is a valid batch group. |
Batch server | An instance of the AOS that processes batch jobs |
Batch Framework Capabilities
As
a system administrator or developer, you can use the new server-based
Batch framework to create larger, more complex batch jobs than before.
You can also monitor the status of batch jobs and control which AOS runs
the batch job and at what time. The following list includes specific
tasks you can do with the new Batch framework capabilities in Dynamics
AX 2009:
Run server-based batch jobs using the
security credentials of the user who created the job. Running the batch
job under the credentials of the user who created the job provides the
benefits of security isolation.
Create
dependencies between batch tasks, and control the order in which the
tasks are executed. The tasks in a batch job can run sequentially or
simultaneously. You can set up a different sequence of tasks, depending
on whether an earlier task succeeds or fails.
Set
the time at which the batch job is executed, and specify which AOS
executes the batch job. The servers in your environment might have
different software installed or might be available at different times of
the day. You can select the most appropriate server on which to run a
batch job using the Batch Group attribute.
Create
recurrence patterns for batch jobs. Some batch jobs need to be run on a
recurring basis. For example, your company might need to process
invoices automatically at the end of every month.
Monitor the batch job. You can ask for an alert to be sent when a batch job succeeds or fails, or just when it finishes.
Check
the status, cancel, or review the history of the batch job. After a
batch job has been processed, you can view its history, including any
messages encountered while running the job.
Performance
Along with more complex and larger batch jobs
comes the need for performance enhancements to the Batch framework. The
Dynamics AX 2009 Batch framework provides parallel execution to improve
performance for long-running processes.
Microsoft developers use the Batch framework as a
foundation for many performance-critical processes, such as maximizing
hardware scalability during data upgrade and maximizing posting
throughput during journal posting. The white paper “Journal Batch
Posting,” available at http://www.microsoft.com/downloads/en/default.aspx, describes many of the ways in which Microsoft uses the Batch framework.
Because it is a server-based component, the
Batch framework enables you to design multithreading server processes in
a controlled manner. By configuring the number of parallel execution
threads, defining the set and order of tasks for processing, and setting
the execution schedule, you can achieve greater scalability across your
hardware. In addition, your batch tasks are running securely on a
server, so you can process them without having a client open.
2. Common Uses of Batch Processing
Businesses typically want to create batch jobs to address the following kinds of needs:
To enable scheduling flexibility
The Batch framework can perform periodic data clean-up jobs or run
invoice processing on a regular schedule. To run invoice processing at
the end of every month, for example, you could set up a recurring batch
job that runs at midnight on the last working day of each month and
selects the invoice processing job from the list of available jobs. You
could then save the schedule (along with its batch job), and the system
automatically picks up the job at the specified time and executes it
without having to open the client.
To control task execution order
With the Batch framework, you can develop a workflow or perform a
complex data upgrade in an order you choose. When creating a new batch
job and adding tasks to the job, you can set up dependencies between the
jobs and create a dependency tree that ensures that certain tasks run
in sequence while others run in parallel.
To enable different processing if a particular task succeeds or fails Task
processing based on decision trees can help you implement a reliable
way of processing data. The Batch framework allows developers or system
administrators to set up dependencies between tasks such that different
tasks are executed depending on whether a particular task succeeds or
fails. The
system administrator or developer can also set up alerts to be notified
if a job fails for any reason.
To improve performance using multithreading
Multithreading ensures that your processor’s capabilities are fully
utilized, which is particularly important for long-running processes
like inventory closing. You can gain additional performance enhancements
by breaking a process into separate subjobs and executing them against
different AOS instances, increasing throughput and reducing overall
execution time.
To gain advanced logging capabilities
The Batch framework lets you see errors or exceptions thrown during the
last run of the batch and to see how long a process takes to execute.
Advanced logging capabilities are also useful for performance
benchmarking and security auditing.